﻿@using Newtonsoft.Json
@using Skoruba.IdentityServer4.Admin.UI.Helpers
@if (ViewBag.Notifications != null)
{
	var settings = new JsonSerializerSettings
	{
		TypeNameHandling = TypeNameHandling.All
	};

	var obj = JsonConvert.DeserializeObject<List<NotificationHelpers.Alert>>(ViewBag.Notifications, settings);

	foreach (NotificationHelpers.Alert notification in obj)
	{
		switch (notification.Type)
		{
			case NotificationHelpers.AlertType.Success:
				<script type="text/javascript">toastr.options.closeButton = true; toastr.success('@notification.Message', '@notification.Title');</script>
				break;
			case NotificationHelpers.AlertType.Error:
				<script type="text/javascript">toastr.error('@notification.Message', '@notification.Title');</script>
				break;
			case NotificationHelpers.AlertType.Info:
				<script type="text/javascript">toastr.options.closeButton = true; toastr.info('@notification.Message', '@notification.Title');</script>
				break;
			case NotificationHelpers.AlertType.Warning:
				<script type="text/javascript">toastr.options.closeButton = true; toastr.warning('@notification.Message', '@notification.Title');</script>
				break;
		}
	}
}